//
//  MCTools.m
//  ZXZX
//
//  Created by menhao on 2018/8/30.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCTools.h"
#import "MCGetIPAdress.h"

@implementation MCTools

-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.psw forKey:@"psw"];
    [aCoder encodeObject:self.status forKey:@"status"];
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self) {
        
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.psw = [aDecoder decodeObjectForKey:@"psw"];
        self.status = [aDecoder decodeObjectForKey:@"status"];
        
    }
    return self;
}



+ (void)requestHelper:(NSMutableURLRequest *)request{
    NSString *uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
    NSString *ip =  [MCGetIPAdress getIPAddress:YES];
    [request addValue:uuid forHTTPHeaderField:@"X-APP-CID"];
    [request addValue:[NSString getAgentInfo] forHTTPHeaderField:@"X-APP-AGENT"];
    [request addValue:@"JAVAAPI" forHTTPHeaderField:@"X-PROTOCOL"];
    [request addValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"] forHTTPHeaderField:@"userId"];
    NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"cookie_id"];
    [request addValue:str forHTTPHeaderField:@"APIID"];
    
    [request addValue:ip forHTTPHeaderField:@"X-APP-IP"];
}
@end
